package top.lishou.learnplat.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.lishou.learnplat.entity.Message;
import top.lishou.learnplat.entity.Senior;
import top.lishou.learnplat.mapper.SeniorMapper;
import top.lishou.learnplat.service.ISeniorService;

import java.util.List;

@Service
public class ISeniorServiceImpl implements ISeniorService {

    @Autowired
    private SeniorMapper seniorMapper;

    @Override
    public Senior getSeniorById(Integer id) {
        return seniorMapper.selectById(id);
    }

    @Override
    public List<Senior> searchSeniorsBySchool(String school) {
        return seniorMapper.selectBySchool(school);
    }

    @Override
    public boolean addMessage(Message message) {
        // 假设这里有一个方法可以保存消息到数据库
        return seniorMapper.insertMessage(message) > 0;
    }

    @Override
    public List<Message> getMessagesBySeniorId(Integer id) {
        // 假设这里有一个方法可以从数据库获取指定senior的所有留言
        return seniorMapper.selectMessagesBySeniorId(id);
    }
}